package com.onstar.cn.framework.network;


import com.onstar.cn.common.util.CommonUtil;

import java.util.UUID;

/**
 * Created by OnStar on 2017/2/28.
 */

public class ClientTraceInstance {
    private static final String BLANK_IDPID = "blank";
    private static final String TRACE_ID_SEPERATE = "|";
    private static final String O_UUID = UUID.randomUUID().toString();
    private String mIdpId = "";


    private static class Inner {
        private final static ClientTraceInstance instance = new ClientTraceInstance();
    }
    private ClientTraceInstance() {
    }

    public static ClientTraceInstance getInstance() {
        return Inner.instance;
    }

    public void setIdpId(String idpId) {
        this.mIdpId = idpId;
    }

    public String getClientTraceId() {
        mIdpId = CommonUtil.isNull(mIdpId)? BLANK_IDPID : mIdpId;
        return  O_UUID + TRACE_ID_SEPERATE +
                mIdpId + TRACE_ID_SEPERATE +
                Long.toHexString(System.currentTimeMillis());
    }
}
